package com.ww.springboot.boot.algorithm.leetcode1;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2023-07-22 17:06
 */
public class DF860 {

    public static void main(String[] args) {

        int[] bills = {5,5,10,10,20};
        System.out.println(lemonadeChange(bills));
    }

    public static boolean lemonadeChange(int[] bills) {
        int num_5 = 0,num_10 = 0;

        for (int i = 0; i < bills.length; i++) {
            switch (bills[i]){
                case 5:
                    num_5++;
                    break;
                case 10:
                    num_10++;
                    num_5--;
                    break;
                case 20:
                    if(num_10>0){
                        num_10--;
                        num_5--;
                    }else {
                        num_5 -= 3;
                    }
                    break;
            }
            if(num_5 < 0){
                return false;
            }
        }
        return true;
    }
}
